package pub.cleangao.common.event;


import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


public class ReactEvent implements IReactEvent, Serializable {


    public ReactEvent() {
    }

    public static ReactEvent sudden(String key) {
        ReactEvent event = new ReactEvent();
        event.setKey(key);
        event.setTimestamp(System.currentTimeMillis());
        event.setMetaData(new HashMap<>());
        return event;
    }

    private String key;
    private String module;
    private String name;
    private long timestamp = System.currentTimeMillis();
    private Map<String, Object> metaData = new HashMap<>();

    public ReactEvent setKey(String key) {
        this.key = key;
        return this;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getModule() {
        return module;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public long getTimestamp() {
        return timestamp;
    }

    private void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public Map<String, ?> getMetaData() {
        return metaData;
    }

    private void setMetaData(Map<String, Object> metaData) {
        this.metaData = metaData;
    }

    public ReactEvent setModule(String module) {
        this.module = module;
        return this;
    }

    public ReactEvent setName(String name) {
        this.name = name;
        return this;
    }


    public ReactEvent setMetaData(String key, Object value) {
        this.metaData.put(key, value);
        return this;
    }
}
